<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

    <!-- 满足有些用户在手机端访问的需要 -->

    <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Expires" content="0">

    <title>用户管理</title>
    <!-- 线上环境 -->
    <link rel="stylesheet" href="/static/css/dist/component-min.css">
    <link rel="stylesheet" href="/static/plugins/jbox/jbox-min.css">

    <!--vue-->
    <script src="/static/vue/vue.js"></script>
    <!--element ui-->
    <script src="/static/element/index.js"></script>
    <link rel="stylesheet" href="/static/element/index.css">
    <style>
        .el-table__empty-block {
            height: 0;
        }
    </style>

</head>
<body class="cp-bodybox">
<div id="app">
    <#include "/common/header-fg.html" />

    <div class="container">
        <div class="inner clearfix">
            <#include "/common/left-menu-fg.html" />

            <div class="content-right">
                <h1 class="content-right-title">平台积分管理</h1>
                <el-card class="box-card">
                    <el-row :gutter="20">
                        <el-col :span="5">
                            <span style="display: inline-block; font-size: 15px;">已发积分总和</span>&nbsp;&nbsp;&nbsp;<h3 style="font-size: 30px;display: inline-block">{{sendTotal}}</h3>
                        </el-col>
                        <el-col :span="5">
                            <span style="display: inline-block; font-size: 15px;">已用积分总和</span>&nbsp;&nbsp;&nbsp;<h3 style="font-size: 30px;display: inline-block">{{usedTotal}}</h3>
                        </el-col>
                    </el-row>
                </el-card>
                <el-card class="box-card" style="margin-top: 10px">
                    <el-form :model="pointsForm" label-width="80px">
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="客户">
                                    <el-input style="width: 200px" v-model="pointsForm.keyword" placeholder="昵称/手机号"></el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="12">
                                <el-form-item label="操作时间">
                                    <el-date-picker
                                            v-model="pointsForm.from"
                                            type="date"
                                            placeholder="选择日期">
                                    </el-date-picker>&nbsp;至&nbsp;
                                    <el-date-picker
                                            v-model="pointsForm.to"
                                            type="date"
                                            placeholder="选择日期">
                                    </el-date-picker>
                                </el-form-item>
                            </el-col>
                            <el-col :span="12">
                                <el-form-item label="类型">
                                    <el-select multiple v-model="pointsForm.bizTypeList" placeholder="请选择类型">
                                        <el-option label="交易获得" value="1"></el-option>
                                        <el-option label="交易使用" value="2"></el-option>
                                        <el-option label="抽奖获得" value="3"></el-option>
                                        <el-option label="抽奖使用" value="4"></el-option>
                                        <el-option label="兑换余额" value="5"></el-option>
                                        <el-option label="系统赠送" value="6"></el-option>
                                        <el-option label="交易退还" value="7"></el-option>
                                        <el-option label="分销获得" value="8"></el-option>
                                        <el-option label="签到获得" value="9"></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                            <el-col :span="12">
                                <el-form-item label="操作类型">
                                    <el-radio-group style="padding-top: 10px;" v-model="pointsForm.operateType">
                                        <el-radio :label="-1">全部</el-radio>
                                        <el-radio :label="0">-</el-radio>
                                        <el-radio :label="1">+</el-radio>
                                    </el-radio-group>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12" style="padding-left: 12px;">
                                <span style="display: inline-block; font-size: 15px;">已发积分</span>&nbsp;&nbsp;&nbsp;<h3 style="font-size: 25px;display: inline-block">{{searchSendTotal}}</h3>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                <span style="display: inline-block; font-size: 15px;">已用积分</span>&nbsp;&nbsp;&nbsp;<h3 style="font-size: 25px;display: inline-block">{{searchUsedTotal}}</h3>
                            </el-col>
                            <el-col :span="12">
                                <div style="text-align: right">
                                    <el-button type="primary" @click.native.prevent="doSearch">查询</el-button>
                                    <el-button @click.native.prevent="clearSearch">清空查询条件</el-button>
                                </div>
                            </el-col>
                        </el-row>
                    </el-form>
                </el-card>
                <el-card class="box-card" style="margin-top: 10px">
                    <div slot="header" class="clearfix">
                        <el-button v-if="isPermission('point:statisticsExport', user.permissions)" type="primary" @click="doExport">导出</el-button>
                    </div>
                    <el-table
                            :data="list"
                            border
                            style="width: 100%">
                        <el-table-column
                                inline-template
                                label="序号"
                                align="center"
                                width="80">
                            <div>{{ $index+pageSize*(currentPage-1)+1 }}</div>
                        </el-table-column>
                        <el-table-column
                                inline-template
                                label="客户昵称"
                                width="180">
                            <template>
                                <el-button type="text" @click="goCustomerDetail(row.customerId)">{{row.customerNick}}</el-button>
                            </template>
                        </el-table-column>
                        <el-table-column
                                prop="tel"
                                label="手机号"
                                width="180">
                        </el-table-column>
                        <el-table-column
                                inline-template
                                label="来源/用途"
                                :show-overflow-tooltip="true"
                                width="200">
                            <div>【{{row.typeName}}】
                                <div v-if="row.type === 2">
                                    <el-button type="text" @click="goOrderDetail(row.orderId)">{{row.orderCode}}</el-button>
                                </div>
                            </div>
                        </el-table-column>
                        <el-table-column
                                inline-template
                                align="center"
                                label="积分变化">
                            <div>{{row.operateType === 1 ? "+" : "-"}}{{row.point}}</div>
                        </el-table-column>
                        <el-table-column
                                prop="insertTime"
                                align="center"
                                show-overflow-tooltip
                                label="时间">
                        </el-table-column>
                        <el-table-column
                                prop="bizDesc"
                                label="备注">
                        </el-table-column>
                        <el-table-column
                                prop="operatorName"
                                label="操作人">
                        </el-table-column>
                    </el-table>
                    <el-pagination
                            @current-change="handleCurrentPageChange"
                            :current-page="currentPage"
                            :page-size="pageSize"
                            layout="total, prev, pager, next"
                            :total="totalCount"
                            style="margin-top: 10px;">
                    </el-pagination>
                </el-card>
            </div>
            <!-- end content-right -->

            <a href="javascript:;" class="btn-leftMenuFold" id="j-btn-leftMenuFold"></a>
        </div>
    </div>
    <!-- end container -->

    <!--gonggao-->

    <!--tip-->
    <div class="footer">© 2017 , Inc. All rights reserved.</div>
    <!-- end footer -->
    <div class="fixedBar" style="right: -78px;">
        <ul>
            <template v-for="(item, index) in leftMenuList">
                <li v-if="index==0" :class="'shopManager' + index + ' cur'"><a href="javascript:;" :data-target="'#shop_' + index">{{item.groupName}}</a></li>
                <li v-else :class="'shopManager' + index"><a href="javascript:;" :data-target="'#shop_' + index">{{item.groupName}}</a></li>
            </template>
        </ul>
        <a href="javascript:;" class="fixedBar-btn" id="j-fixedBar-btn"></a>
    </div>
    <a href="#" id="j-gotop" class="gotop" title="回到顶部" style="left: 1920.59px;"></a>

</div>
<script src="/static/js/dist/lib-min.js"></script>
<script src="/static/js/dist/list.js"></script>
<script src="/static/js/dist/component-min.js"></script>
<script src="/static/js/common.js"></script>

<!-- 引入api -->
<script src="/static/js/api.js"></script>
<script>
    new Vue({
        el: '#app',
        data: function(){
            return {
                user: ${(user)!'null'},
                sendTotal: ${(sendTotal)!'0'},
                usedTotal: ${(usedTotal)!'0'},
                searchSendTotal: ${(sendTotal)!'0'},
                searchUsedTotal: ${(usedTotal)!'0'},
                headerNavList: list.headerNavList,
                accountNavList: list.accountNavList,
                leftMenuList: list.menu,
                currentPage: list.currentPage,
                pageSize: list.pageSize,
                totalCount:0,
                list: [],
                pointsForm: {
                    keyword: '',
                    from: '',
                    to: '',
                    bizTypeList: [],
                    operateType: -1
                }
            }
        },
        mounted:function () {
            this.getList();
        },
        methods: {
            doExport () {
                let url = ''
                if (this.pointsForm.keyword !== '') {
                    if (url !== '') {
                        url += "&"
                    }
                    url += "keyword=" + this.pointsForm.keyword
                }
                if (this.pointsForm.from !== '') {
                    if (url !== '') {
                        url += "&"
                    }
                    url += "from=" + this.pointsForm.from
                }
                if (this.pointsForm.to !== '') {
                    if (url !== '') {
                        url += "&"
                    }
                    url += "from=" + this.pointsForm.to
                }
                if (this.pointsForm.operateType !== '' && this.pointsForm.operateType !== -1) {
                    if (url !== '') {
                        url += "&"
                    }
                    url += "operateType=" + this.pointsForm.operateType
                }
                if (this.pointsForm.bizTypeList.length > 0) {
                    for (let i=0; i<this.pointsForm.bizTypeList.length; i++) {
                        if (url !== '') {
                            url += "&"
                        }
                        url += "bizTypeList=" + parseInt(this.pointsForm.bizTypeList[i])
                    }
                }
                if (url !== '') {
                    url = '/pointStatistics/outPut?' + url
                } else {
                    url = '/pointStatistics/outPut'
                }
                window.open(url);
            },
            goCustomerDetail (customerId) {
                window.open("/customer/detail?id=" + customerId)
            },
            goOrderDetail (orderId) {
                window.open("/order/detail?orderId=" + orderId)
            },
            doSearch () {
                this.currentPage = 1
                this.getList()
            },
            handleCurrentPageChange(val) {
                this.currentPage = val;
                this.getList();
            },
            formatterTime (row, column) {
                if (row.applyTime !== undefined && (row.applyTime + "").length >= 10) {
                    return (row.applyTime + "").substring(0, 10);
                } else {
                    return row.applyTime;
                }
            },
            getList(){
                let that = this;
                let obj = {
                    keyword: this.pointsForm.keyword,
                    from: this.formatTime(this.pointsForm.from, true),
                    to: this.formatTime(this.pointsForm.to, true),
                    bizTypeList: this.pointsForm.bizTypeList,
                    operateType: this.pointsForm.operateType,
                    currentPage: this.currentPage,
                    pageSize: this.pageSize,
                    isAll: 0
                }
                this.http('/pointStatistics/list', obj, function (res) {
                    if(res.status == 200){
                        that.list = res.data.pointList;
                        that.totalCount = res.data.total;
                        that.searchSendTotal = res.data.searchSendTotal;
                        that.searchUsedTotal = res.data.searchUsedTotal;
                    }else{
                        that.$alert('服务器错误','提示',{
                            confirmButtonText:'确定'
                        })
                    }
                },function (res) {
                    that.$alert('服务器错误','提示',{
                        confirmButtonText:'确定'
                    })
                })
            },
            clearSearch(){
                this.pointsForm.keyword = ''
                this.pointsForm.from = ''
                this.pointsForm.to = ''
                this.pointsForm.bizTypeList = []
                this.currentPage = 1
                this.getList()
            }
        }
    })
</script>

<!-- 20170105 --></body>
</html>